# First stage: complete build environment.
FROM maven:3.5.0-jdk-8-alpine AS builder

# add pom.xml and source code.
ADD . .

# package jar
RUN mvn clean package -DskipTests

# Second stage: minimal runtime environment.
From openjdk:8-jre-alpine
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
#增加字体 解决验证码没有字体报空指针问题
RUN set -xe \
&& apk --no-cache add ttf-dejavu fontconfig
# set timezone
RUN apk add -U tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && apk del tzdata
# copy jar from the first stage
COPY --from=builder imc-admin/target/*.jar app.jar

# mount dir
VOLUME /tmp

EXPOSE 8080
ENTRYPOINT ["java","-Duser.timezone=GMT+8","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
